package com.woniu.controller;

import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDictType;
import com.ruoyi.common.core.page.TableDataInfo;
import com.woniu.entity.FirstTrail;
import com.woniu.entity.LoanInfo;
import com.woniu.service.FirstTrialService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description: 初审控制层
 * @author: sunkun
 * @date: 2022/9/22 18:39
 * @version 1.0
 */
@Api(value = "初审列表", tags = {"初审"})
@RestController
@RequestMapping("/firstTrial")
public class FirstTrialController extends BaseController {

    @Resource
   private FirstTrialService firstTrialService;

    @ApiOperation("查询所有初审订单")
    @GetMapping("/list")
    public TableDataInfo findFirstTrialList(@ApiParam("初审实体类")FirstTrail firstTrail){
		startPage();
        List<FirstTrail> firstTrialList = firstTrialService.findFirstTrialList(firstTrail);
        return getDataTable(firstTrialList);
    }

    @ApiOperation("更新审核状态")
    @PostMapping("/update")
    public AjaxResult add(@ApiParam("初审实体类")@Validated @RequestBody FirstTrail firstTrail){
        return toAjax(firstTrialService.updateFirstTrial(firstTrail));
    }

    @ApiOperation("根据ID查询单笔订单")
    @GetMapping("/find/{id}")
    public AjaxResult findFirstTrialById(@PathVariable Integer id){
        FirstTrail firstTrial = firstTrialService.findFirstTrialById(id);
        return new AjaxResult(HttpStatus.SUCCESS,"查询成功",firstTrial);
    }

}
